﻿namespace MathService.Values
{
    public class MaxValue : IValue<double>, IResetable
    {
        private double f_Value;

        public double Value { get { return f_Value; } set { f_Value = value; } }

        public MaxValue() { f_Value = double.MinValue; }
        public MaxValue(double StartValue) { f_Value = StartValue; }

        public bool AddValue(double value)
        {
            if(value > f_Value) { f_Value = value; return true; }
            return false;
        }

        public void Reset() { f_Value = double.NegativeInfinity; }

        public override string ToString()
        {
            return f_Value.ToString();
        }

        public string ToString(string FormatString)
        {
            return f_Value.ToString(FormatString);
        }

        public static implicit operator double(MaxValue MaxValue) { return MaxValue.f_Value; }
    }
}